
**** g estimate municipal



clear all



**** use "path ... domenechsanchezcuenca_province.dta"
use "/ ..  domenechsanchezcuenca_BJPS/domenechsanchezcuenca_municipal.dta"

* LEFTvoto: is the share of votes going to Leftist parties (PSOE, PCE, IU)

* carrion_liquido: proxy for agrarian inequality at the municipal level based on cadastral information from Pascual Carrión (1975)

* latitud, longitud, altitud: latitude, longitude and altitude of the municipality. 

* i.year: dummy variables for the 15 elections (14 dummies, base category is the 1977 election)

* munid: municipality identificator

* frentepopularvoto: % share vote for Popular Front, 1936 general election

* CENSO: number of voters in each election

* killed_rebels: summary executions perpetrated by Rightist forces

* tasa_analfabetismo_1930: illiteracy rate, Population census 1930

* popchange19301970: population % change 1930-1970 




rename CódigodeProvincia provid

xtset munid year


**** Table 1, column (2) Baseline regressions [Second regression, excluding municipalities with fewer than 1,000 voters]

reg LEFTvoto  carrion_liquido  latitud longitud altitud i.year, vce(cluster munid)

reg LEFTvoto  carrion_liquido  latitud longitud altitud i.year if CENSO>1000, vce(cluster munid)





**** Table 4 Mediator analysis municipal level. Municipalities in the region of Extremadura


merge m:m munid using "........../domenechsanchezcuenca_BJPS/extremadura_educacionsecundaria.dta"


gen log_censo=log(CENSO)

gen killed_rebels_pop=(killed_rebels/poblacion1930)*100

gen killed_leftists_pop=(killed_leftists/poblacion1930)*100

gen asin_killed_rebels=asinh(killed_rebels)
gen asin_killed_leftists=asinh(killed_leftists)

gen frentepopular_rebels=frentepopularvoto*asin_killed_rebels
gen frentepopular_leftists=frentepopularvoto*asin_killed_leftists

drop if provid==11
drop if provid==29
drop if provid==41
drop if provid==13
drop if provid==37

drop if carrion_liquido==.  


drop if frentepopularvoto==.


**** Table 4


**** Baseline
reg LEFTvoto carrion_liquido altitud latitud longitud i.year if CENSO>1000, vce(cluster munid)

**** column (1) 

reg LEFTvoto carrion_liquido altitud latitud longitud CENSO i.year if CENSO>1000, vce(cluster munid)

reg LEFTvoto carrion_liquido  frentepopularvoto  asin_killed_rebels  altitud latitud longitud i.year CENSO  if CENSO>1000 , vce(cluster munid)



**** column (3) 

reg LEFTvoto carrion_liquido  tasa_analfabetismo_1930 popchange_19301970  CENSO  altitud latitud longitud i.year  if CENSO>1000, vce(cluster munid)

**** column (3) robustness (without #of voters,  CENSO)

reg LEFTvoto carrion_liquido  tasa_analfabetismo_1930 popchange_19301970    altitud latitud longitud i.year  if CENSO>1000, vce(cluster munid)


**** column (2) g-estimate, demeaning mediator variable 

reg LEFTvoto carrion_liquido  frentepopularvoto asin_killed_rebels  CENSO  altitud latitud longitud i.year  if CENSO>1000, vce(cluster munid)

gen coef1=_b[frentepopularvoto]

gen coef2=_b[asin_killed_rebels]


gen LEFTvoto_tilde1=LEFTvoto-(coef1*frentepopularvoto)-(coef2*asin_killed_rebels)

set seed 12345

bootstrap _b[carrion_liquido], size(1000) reps(4000): reg LEFTvoto_tilde1 carrion_liquido altitud latitud longitud CENSO i.year if CENSO>1000


**** column (4) g-estimate, demeaning the intermediate confounders 

reg LEFTvoto c.carrion_liquido  tasa_analfabetismo_1930 popchange_19301970  CENSO  altitud latitud longitud i.year  if CENSO>1000, vce(cluster munid)


gen coef4=_b[tasa_analfabetismo_1930]
gen coef5=_b[popchange_19301970]
gen coef6=_b[CENSO]


gen LEFTvoto_tilde2=LEFTvoto-(coef4*tasa_analfabetismo_1930) - (coef5*popchange_19301970) - (coef6*CENSO)

set seed 12345

bootstrap _b[carrion_liquido], size(1000) reps(4000): reg LEFTvoto_tilde2 carrion_liquido   altitud latitud longitud i.year  if CENSO>1000




